package cn.edu.xmu.oomall.payment.model.vo;

import cn.edu.xmu.oomall.payment.model.bo.Payment;
import cn.edu.xmu.oomall.payment.util.DateTimeTransformation;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.ZonedDateTime;

/**
 * @author 张浩山
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ShopPaymentRetVo {
    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "支付交易流水号")
    private String tradeSn;

    @ApiModelProperty(value = "支付渠道")
    private Long patternId;

    @ApiModelProperty(value = "支付金额")
    private Long amount;

    @ApiModelProperty(value = "实际支付金额")
    private Long actualAmount;

    @ApiModelProperty(value = "单据号")
    private String documentId;

    @ApiModelProperty(value = "单据类型")
    private Byte documentType;

    @ApiModelProperty(value = "实际支付时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd'T'HH:mm:ss.SSS" ,timezone = "GMT+8")
    private ZonedDateTime payTime;

    @ApiModelProperty(value = "开始支付时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd'T'HH:mm:ss.SSS" ,timezone = "GMT+8")
    private ZonedDateTime beginTime;

    @ApiModelProperty(value = "支付截止时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd'T'HH:mm:ss.SSS" ,timezone = "GMT+8")
    private ZonedDateTime endTime;

    @ApiModelProperty(value = "支付状态")
    private Byte state;

    @ApiModelProperty(value = "备注")
    private String descr;

    public ShopPaymentRetVo(Payment payment) {
        id = payment.getId();
        tradeSn = payment.getTradeSn();
        patternId = payment.getPatternId();
        amount = payment.getAmount();
        actualAmount = payment.getActualAmount();
        documentId = payment.getDocumentId();
        documentType = payment.getDocumentType();
        payTime = DateTimeTransformation.getZonedDateTime(payment.getPayTime());
        beginTime = DateTimeTransformation.getZonedDateTime(payment.getBeginTime());
        endTime = DateTimeTransformation.getZonedDateTime(payment.getEndTime());
        state = payment.getState();
        descr = payment.getDescr();
    }
}
